package com.example.librarymanagement.dto.borrowrecord;

import com.example.librarymanagement.entity.BorrowRecord;
import com.example.librarymanagement.util.BaseDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @author LQS
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
public class BorrowRecordUpdDto extends BaseDto<BorrowRecord> {

    @ApiModelProperty(value = "id", required = true)
    @NotNull(message = "id值不能为空")
    private Integer id;

    @ApiModelProperty(value = "应还日期")
    @NotNull(message = "应还日期不能为空")
    private Date shouldReturnDate;

    @ApiModelProperty(value = "实还日期")
    private Date returnDate;

    @ApiModelProperty(value = "借阅状态")
    @NotNull(message = "状态不能为空")
    private Integer state;

    @Override
    public void convertToEntity(BorrowRecord entity) {
        entity.setId(this.getId());
        entity.setShouldReturnDate(this.getShouldReturnDate());
        entity.setReturnDate(this.getReturnDate());
        entity.setState(this.getState());
    }
}
